import 'package:dodoclub/pages/comm/comm_controller.dart';
import 'package:dodoclub/widgets/square_item.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class SquarePage extends StatelessWidget {
  SquarePage({super.key});

  final CommController controller = Get.put(CommController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFFf1f2f3),
      appBar: AppBar(
        scrolledUnderElevation: 0.0,
        title: Text(
          'Square',
        ),
        actions: <Widget>[
          IconButton(
            icon: const Icon(
              Icons.control_point_sharp,
              size: 22,
              // color: Colors.grey,
            ),
            onPressed: () {
              // tagsController.setTagItem(SpinnerItemData(
              //     name: '问升学', result: '问升学', selected: false, isMutex: false));
              //Toast.show("跳转到添加笔记页面", gravity: 1);
              Get.toNamed("/add/add");
            },
          )
        ],
      ),
      body: Padding(
          padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
          child: Obx(
            () {
              return ListView.builder(
                itemCount: controller.items.length,
                itemBuilder: (context, index) {
                  var item = controller.items[index];
                  return Container(
                    margin: (index == 0)
                        ? EdgeInsets.only(top: 8.0)
                        : EdgeInsets.only(top: 8.0), // 设置上边距
                    padding: EdgeInsets.all(8.0), // 其他内边距
                    decoration: BoxDecoration(
                      color: Color.fromARGB(255, 197, 245, 168),
                      borderRadius: BorderRadius.circular(8.0),
                    ),
                    child: SquareItem(
                      index: index,
                      item: item,
                    ),
                  );
                },
                // separatorBuilder: (context, index) => Container(
                //   height: 4,
                // ),
              );
            },
          )),
    );
  }
}
